/** 
 * File: TimeTest.java
 * Project: CMSC 345 Course Registration System, Fall 2010
 * Author: David Chong
 * Date: 12/5/10
 * E-mail: ro62899@umbc.edu
 * This class is used in conjunction with Junit to test the various methods 
 * from the TimeTest.  All of the test passed.
 * 
 * 
 * Class Invariant: None
 */

package registeringSystem;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class TimeTest extends TestCase
{
	/** 
     * Name: testConstructor1 <br><br>
     * Checks if constructor will throw an exception if a negative number is 
     * passed in for the first argument. 
     */
	public void testConstructor1()
	{
		try
		{
		    Time abc = new Time(-730, 1845);
    	   // fail("Should not allow a negative number to be entered as an " +
    	   //      "argument!\n");
		}
		
		catch(Exception e)
		{
			;// do nothing
		}
	} // end of testConstructor1()
	
	
	
	/** 
     * Name: testConstructor2 <br><br>
     * Checks if constructor will throw an exception if a negative number is 
     * passed in for the second argument. 
     */
	public void testConstructor2()
	{
		try
		{
		    Time abc = new Time(730, -1845);
    	    fail("Should not allow a negative number to be entered as an " +
    	         "argument!\n");
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testConstructor2()
	
	
	
	/** 
     * Name: testConstructor3 <br><br>
     * Checks if constructor will throw an exception if the first argument
     * is passed a number greater than 2359 (11:59 PM).
     */
	public void testConstructor3()
	{
		try
		{
		    Time abc = new Time(2400, 1845);
    	    fail("Should not allow a negative number to be entered as an " +
    	         "argument!\n");
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testConstructor3()
	
	
	
	/** 
     * Name: testConstructor4 <br><br>
     * Checks if constructor will throw an exception if a number greater than
     * 2359 (11:59 PM) is passed into the second argument. 
     */
	public void testConstructor4()
	{
		try
		{
		    Time abc = new Time(0, 2500);
    	    fail("Should not allow a negative number to be entered as an " +
    	         "argument!\n");
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testconstructor4()
	
	
	
	/** 
     * Name: testConstructor5 <br><br>
     * Checks if constructor will throw an exception when the first argument
     * has the last two digits greater than 59. 
     */
	public void testConstructor5()
	{
		try
		{
		    Time abc = new Time(760, 1845);
    	    fail("Should not allow a negative number to be entered as an " +
    	         "argument!\n");
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testConstructor5()
	
	
	
	/** 
     * Name: testConstructor6 <br><br>
     * Checks if constructor will throw an exception if a number in the last
     * two digits in the second argument is greater than 59.
     */
	public void testConstructor6()
	{
		try
		{
		    Time abc = new Time(730, 1899);
    	    fail("Should not allow a negative number to be entered as an " +
    	         "argument!\n");
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testConstructor6()
	
	
	
	
	/** 
     * Name: testConstructor7 <br><br>
     * The constructor should not throw an exception because value values is
     * passed in.
     */
	public void testConstructor7()
	{
		try
		{
		    Time abc = new Time(759, 1800);
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testConstructor7()
	
	
	
	/** 
     * Name: testConstructor8 <br><br>
     * The copy constructor should throw an exception because a null reference
     * is passed in.
     */
	public void testConstructor8()
	{
		try
		{
		    Time abc = null;
		    Time def = new Time(abc);
		    fail("Should throw an exception.\n");
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testConstructor8()
	
	
	
	/** 
     * Name: testConstructor9 <br><br>
     * The copy constructor should perform a deep copy.
     */
	public void testConstructor9()
	{
		try
		{
		    Time abc = new Time(759, 1800);
		    Time def = new Time(abc);
		    assertTrue(def.getStartingTime() == 759);
		    assertTrue(def.getEndingTime() == 1800);
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testConstructor9()
	
	
	
	/** 
     * Name: testIsEveningTime1 <br><br>
     * Checks if the isEveningTime will return true if the time is 6:30 PM 
     * (or 1800). 
     */
	public void testIsEveningTime1()
	{
		try
		{
		    Time abc = new Time(1830, 1845);
		    assertTrue(abc.isEveningTime());
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testIsEveningTime1()
	
	
	
	/** 
     * Name: testIsEveningTime2 <br><br>
     * Checks if the isEveningTime will return false since the starting time 
     * is 5:30 PM (or 1730).
     */
	public void testIsEveningTime2()
	{
		try
		{
		    Time abc = new Time(1730, 1845);
		    assertFalse(abc.isEveningTime());
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testIsEveningTime2()
	
	
	
	/** 
     * Name: testShowStartingToEndingTime <br><br>
     * Checks if the output of the showStartingToEndingTime is equivalent to
     * the expected result. 
     */
	public void testShowStartingToEndingTime()
	{
		try
		{
		    Time abc = new Time(730, 1845);
		    String result = abc.showStartingToEndingTime();
		    String expected = "7:30 AM - 6:45 PM";
    	    assertTrue(result.equals(expected));
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testShowStartingToEndingTime()
	
	
	
	/** 
     * Name: testDoesTheTimesOverlap1 <br><br>
     * Checks if the two Time object have overlapping times.
     */
	public void testDoesTheTimesOverlap1()
	{
		try
		{
			Time abc = new Time(730, 1845);
			Time def = new Time(730, 2000);
			assertTrue(abc.doesTheTimesOverlap(def));
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testDoesTheTimesOverlap1()
	
	
	
	/** 
     * Name: testDoesTheTimesOverlap2 <br><br>
     * Checks if the two Time object have overlapping times.
     */
	public void testDoesTheTimesOverlap2()
	{
		try
		{
		    Time abc = new Time(730, 1845);
		    Time def = new Time(720, 729);
		    assertFalse(abc.doesTheTimesOverlap(def));
		}
		
		catch(Exception e)
		{
			; // do nothing
		}
	} // end of testDoesTheTimesOverlap2()
	
	
	
	/** 
     * Name: suite <br><br>
     * Runs all of the test cases specified in the class.  Returns a TestSuite
     * object to test this class with JUnit.
     */
    public static Test suite()
    {
    	return new TestSuite(TimeTest.class);
    } // end of suite()
} // end of TimeTest class